package com.common.security.errors;

import com.common.security.abstracts.AbstractError;

/**
 * Error code range: 41 - 60
 * 
 * @author Ady
 *
 */
public class ParserError extends AbstractError {

	public static final int MULTIPLE_ACTIONS_PROVIDED = 41;
	private static final String MESSAGE_MULTIPLE_ACTIONS_PROVIDED = "More than one Action tag was provided";
	private static final String CAUSE_MULTIPLE_ACTIONS_PROVIDED = "Two or more Action tags provided";
	private static final String DESCRIPTION_MULTIPLE_ACTIONS_PROVIDED = "The XML must have one and only one Action tag";
	
	public static final int MULTIPLE_CONTENTS_PROVIDED = 42;
	private static final String MESSAGE_MULTIPLE_CONTENTS_PROVIDED = "More than one Content tag was provided";
	private static final String CAUSE_MULTIPLE_CONTENTS_PROVIDED = "Two or more Content tags provided";
	private static final String DESCRIPTION_MULTIPLE_CONTENTS_PROVIDED = "The XML must have one and only one Content tag";

	public static final int NO_ACTION_PROVIDED = 43;
	private static final String MESSAGE_NO_ACTION_PROVIDED = "No Action tag was provided";
	private static final String CAUSE_NO_ACTION_PROVIDED = "You forgot to add an Action tag";
	private static final String DESCRIPTION_NO_ACTION_PROVIDED = "Add an Action tag in the XML";
	
	public static final int NO_CONTENT_PROVIDED = 44;
	private static final String MESSAGE_NO_CONTENT_PROVIDED = "No Content tag was provided";
	private static final String CAUSE_NO_CONTENT_PROVIDED = "You forgot to add a Content tag";
	private static final String DESCRIPTION_NO_CONTENT_PROVIDED = "Add a Content tag in the XML";

	public static final int STREAM_ERROR = 45;
	private static final String MESSAGE_STREAM_ERROR = "The request's stream was closed unexpected";
	private static final String CAUSE_STREAM_ERROR = "The stream was closed or there is no access to it";
	private static final String DESCRIPTION_STREAM_ERROR = "Try again and if the issue persist, please contact the administrator";
	
	public static final int ACTION_BAD_FORMAT = 46;
	private static final String MESSAGE_ACTION_BAD_FORMAT = "The Action tag had an unexpected format";
	private static final String CAUSE_ACTION_BAD_FORMAT = "Parts of the <Action> tag wore missing or it had an invalid format";
	private static final String DESCRIPTION_ACTION_BAD_FORMAT = "Make sure you have a valid format of the Action tag";
	
	public static final int CONTENT_BAD_FORMAT = 47;
	private static final String MESSAGE_CONTENT_BAD_FORMAT = "The Content tag had an unexpected format";
	private static final String CAUSE_CONTENT_BAD_FORMAT = "Parts of the Content tag wore missing or it had an invalid format";
	private static final String DESCRIPTION_CONTENT_BAD_FORMAT = "Make sure you have a valid format of the Content tag";
	
	public static final int ACTION_NOT_AVAILABLE = 48;
	private static final String MESSAGE_ACTION_NOT_AVAILABLE = "The provided action is unavailable";
	private static final String CAUSE_ACTION_NOT_AVAILABLE = "The action never existed or was deleted";
	private static final String DESCRIPTION_ACTION_NOT_AVAILABLE = "Make sure the action exists and the name is spelled correctly";

	public static final int USER_TYPE_NOT_AVAILABLE = 49;
	private static final String MESSAGE_USER_TYPE_NOT_AVAILABLE = "The provided user type is unavailable";
	private static final String CAUSE_USER_TYPE_NOT_AVAILABLE = "The user type never existed or was deleted";
	private static final String DESCRIPTION_USER_TYPE_NOT_AVAILABLE = "Make sure the user type exists and the name is spelled correctly";
	
	public static final int USER_TYPE_NOT_PROVIDED = 50;
	private static final String MESSAGE_USER_TYPE_NOT_PROVIDED = "The user type was not provided";
	private static final String CAUSE_USER_TYPE_NOT_PROVIDED = "You forgot to add the user type tag or value";
	private static final String DESCRIPTION_USER_TYPE_NOT_PROVIDED = "Add the user type tag and value in the request";
	
	public static final int RESPONSE_MATCH_ERROR = 51;
	private static final String MESSAGE_RESPONSE_MATCH_ERROR = "The response does not match the request";
	private static final String CAUSE_RESPONSE_MATCH_ERROR = "The wrong parser was assigned to this method";
	private static final String DESCRIPTION_RESPONSE_MATCH_ERROR = "Please tell the admin about this issue in order to be fixed";
	
	public static final int VALUE_CONVERT_ERROR = 52;
	private static final String MESSAGE_VALUE_CONVERT_ERROR = "The value provided does not have a valid format";
	private static final String CAUSE_VALUE_CONVERT_ERROR = "There might be a missplaced letter or number in the provided value";
	private static final String DESCRIPTION_VALUE_CONVERT_ERROR = "Check that the provided and expected values match and try again";
	
	public static final int RESPONSE_BAD_FORMAT = 53;
	private static final String MESSAGE_RESPONSE_BAD_FORMAT = "The response created had a bad format";
	private static final String CAUSE_RESPONSE_BAD_FORMAT = "The data received may have damaged the server integrity";
	private static final String DESCRIPTION_RESPONSE_BAD_FORMAT = "Please contact the developer and send feedback related to this problem";
	
	public ParserError(int code) {
		super(code);
		
		switch (code) {
			case MULTIPLE_ACTIONS_PROVIDED: {
				setMessage(MESSAGE_MULTIPLE_ACTIONS_PROVIDED);
				setCause(CAUSE_MULTIPLE_ACTIONS_PROVIDED);
				setDescription(DESCRIPTION_MULTIPLE_ACTIONS_PROVIDED);
				break;
			}
			case MULTIPLE_CONTENTS_PROVIDED: {
				setMessage(MESSAGE_MULTIPLE_CONTENTS_PROVIDED);
				setCause(CAUSE_MULTIPLE_CONTENTS_PROVIDED);
				setDescription(DESCRIPTION_MULTIPLE_CONTENTS_PROVIDED);
				break;
			}
			case NO_ACTION_PROVIDED: {
				setMessage(MESSAGE_NO_ACTION_PROVIDED);
				setCause(CAUSE_NO_ACTION_PROVIDED);
				setDescription(DESCRIPTION_NO_ACTION_PROVIDED);
				break;
			}
			case NO_CONTENT_PROVIDED: {
				setMessage(MESSAGE_NO_CONTENT_PROVIDED);
				setCause(CAUSE_NO_CONTENT_PROVIDED);
				setDescription(DESCRIPTION_NO_CONTENT_PROVIDED);
				break;
			}
			case STREAM_ERROR: {
				setMessage(MESSAGE_STREAM_ERROR);
				setCause(CAUSE_STREAM_ERROR);
				setDescription(DESCRIPTION_STREAM_ERROR);
				break;
			}
			case ACTION_BAD_FORMAT: {
				setMessage(MESSAGE_ACTION_BAD_FORMAT);
				setCause(CAUSE_ACTION_BAD_FORMAT);
				setDescription(DESCRIPTION_ACTION_BAD_FORMAT);
				break;
			}
			case CONTENT_BAD_FORMAT: {
				setMessage(MESSAGE_CONTENT_BAD_FORMAT);
				setCause(CAUSE_CONTENT_BAD_FORMAT);
				setDescription(DESCRIPTION_CONTENT_BAD_FORMAT);
				break;
			}
			case ACTION_NOT_AVAILABLE: {
				setMessage(MESSAGE_ACTION_NOT_AVAILABLE);
				setCause(CAUSE_ACTION_NOT_AVAILABLE);
				setDescription(DESCRIPTION_ACTION_NOT_AVAILABLE);
				break;
			}
			case USER_TYPE_NOT_AVAILABLE: {
				setMessage(MESSAGE_USER_TYPE_NOT_AVAILABLE);
				setCause(CAUSE_USER_TYPE_NOT_AVAILABLE);
				setDescription(DESCRIPTION_USER_TYPE_NOT_AVAILABLE);
				break;
			}
			case USER_TYPE_NOT_PROVIDED: {
				setMessage(MESSAGE_USER_TYPE_NOT_PROVIDED);
				setCause(CAUSE_USER_TYPE_NOT_PROVIDED);
				setDescription(DESCRIPTION_USER_TYPE_NOT_PROVIDED);
				break;
			}
			case RESPONSE_MATCH_ERROR: {
				setMessage(MESSAGE_RESPONSE_MATCH_ERROR);
				setCause(CAUSE_RESPONSE_MATCH_ERROR);
				setDescription(DESCRIPTION_RESPONSE_MATCH_ERROR);
				break;
			}
			case VALUE_CONVERT_ERROR: {
				setMessage(MESSAGE_VALUE_CONVERT_ERROR);
				setCause(CAUSE_VALUE_CONVERT_ERROR);
				setDescription(DESCRIPTION_VALUE_CONVERT_ERROR);
				break;
			}
			case RESPONSE_BAD_FORMAT: {
				setMessage(MESSAGE_RESPONSE_BAD_FORMAT);
				setCause(CAUSE_RESPONSE_BAD_FORMAT);
				setDescription(DESCRIPTION_RESPONSE_BAD_FORMAT);
				break;
			}
		}
	}
}
